<?php
    class loaisanphambs
    {
        public $MaLoaiSanPham = 0;
		public $TenLoaiSanPham = '';
        
        public $MaLoaiSanPhamCap1 = 0;
        public $MaLoaiSanPhamCap2 = 0;
        public $MaLoaiSanPhamCap3 = 0;
        
        
        //public $query = isset($_POST['query']) ? $_POST['query'] : false;
        //public $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : false;
        
        //Phân trang
        public $P = 1; //$page
        public $SoLoaiSanPham = 2; //$rp
        public $SapXepTheo = 'MaLoaiSanPham'; //$sortname
        public $SapXepTangGiam = 'ASC'; //$sortorder
        
        public $page = 1; // The current page
        public $sortname = 'MaLoaiSanPham'; // Sort column
        public $sortorder = 'asc'; // Sort order
        
        public $qtype = ''; // Search column
        public $query = ''; // Search string
		
		public function getList($order = '', $start = 0, $num = 30, $all = 1)
		{
			$db = new loaisanphamdb();
			return $db->getList($this->MaLoaiSanPham, $this->TenLoaiSanPham, $order, $start, $num, $all);
		}
        
        public function getIds()
		{
			$db = new loaisanphamdb();
			return $db->getIds($this->MaLoaiSanPhamCap1, $this->MaLoaiSanPhamCap2, $this->MaLoaiSanPhamCap3);
		}
        
        public function totalPageGrid()
        {
            $db = new loaisanphamdb();
			return $db->totalPageGrid($this->qtype, $this->query);
        }
        
        public function getListGrid()
		{
			$db = new loaisanphamdb();
			return $db->getListGrid($this->SoLoaiSanPham, $this->P, $this->SapXepTheo, $this->SapXepTangGiam, $this->qtype, $this->query);
		}
		
		public function add()
		{
			$db = new loaisanphamdb();
			return $db->add($this->TenLoaiSanPham);
		}
		
		public function update()
		{
			$db = new loaisanphamdb();
			return $db->update($this->MaLoaiSanPham,$this->TenLoaiSanPham);
		}
		
		public function delete()
		{
			$db = new loaisanphamdb();
			return $db->delete($this->MaLoaiSanPham);
		}
        
        public function issetTypes()
		{
			$db = new loaisanphamdb();
			return $db->issetTypes($this->MaLoaiSanPham, $this->TenLoaiSanPham);
		}
        
        public function issetType()
		{
			$db = new loaisanphamdb();
			return $db->issetType($this->TenLoaiSanPham);
		}
		
		public function totalPage()
        {
            $db = new loaisanphamdb();
			return $db->totalPage($this->SoLoaiSanPham);
        }
        
        public function paging()
        {
            $db = new loaisanphamdb();
			return $db->paging($this->SoLoaiSanPham, $this->P);
        }
    }
?>